<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="com.sz.common.ICommonDAO" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String business_id = request.getParameter("business_id");
String src = "page/business_summary.jsp?business_id=" + business_id;

String style1 = "width: 80;text-align:right;font-size: 12px;";
String style2 = "width: 120px";
String style3 = "color: red;text-align:left;";
String style4 = "font-size: 12px;";

%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<link href="<%= request.getContextPath() %>/css/main.css" rel="stylesheet" type="text/css" />		
		<base href="<%=basePath%>" target="_self">
		<title>新增订单</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="addTicket">
		<meta http-equiv="description" content="新增订单">
	</head>
	
	<body>
		<script type="text/javascript" src="js/calendar.js"></script>
		<script type="text/javascript" src="js/utility.js"></script>	
		
	  	<form name="addTicket_form"  action="ticket/addTicket.exec" method="post" onsubmit="return check()"> 
	  	 <table width="100%" border="0" >
	  	 
  		<tr>
		  	<td style="<%=style1%>">客户电话</td>
		  	<td>
		  		<input type="text" id="cust_tel" name="cust_tel"  style="<%=style2%>">
		  		<font style="<%=style3%>">*</font>
		  	</td>
		  	
		  	
		  	<td style="<%=style1%>">客户姓名</td>
		  	<td>
		  		<input type="text" id="cust_name" name="cust_name" style="<%=style2%>">
		  		<font style="<%=style3%>">*</font>
		  	</td>
		  			  	
		  	<td style="<%=style1%>">客户性别</td>
		  	<td style="<%=style4%>">
		  		<input type="radio" id="sex_male" onclick="onClickRadio_sex('sex_male')">男
		  		<input type="radio" id="sex_female" onclick="onClickRadio_sex('sex_female')">女
		  		<input type="radio" id="sex_unknown" onclick="onClickRadio_sex('sex_unknown')">未知
		  	</td>
		  	
		  	<td style="<%=style1%>">电子邮箱</td>
		  	<td>
		  		<input type="text" id="email" name="email" style="<%=style2%>" >	  		
		  	</td>
	  	</tr>

	  	<tr>
	  		<td style="<%=style1%>">商旅卡号</td>
	  		<td>
	  			<input type="text" id="card_no" name="card_no" style="<%=style2%>" >
	  		</td>
	  		
		  	<td style="<%=style1%>">预约时间</td>
		  	<td>
		  		<input type="text" id="demand_time_d" name="demand_time_d" readonly="readonly" style="width: 95px;" onclick="calendar.show(this)" >
		  		<select id="demand_time_t" name="demand_time_t" style="width: 80px;" >
		  		  <option selected="selected"></option>
		  		  <%
		  		  String value;
		  		  String text;
		  		  String value_half;
		  		  String text_half;
				  for(int n = 0; n < 24; ++n) {
					  String t = String.valueOf(n);					  
					  value = t + ":" + "00";
					  text = t + "时";
					  
					  value_half = t + ":" + "30";
					  text_half = " " + t + "时" + "30分";
				  %>
				  <option 
				    value="<%=value%>"><%=text%>
				  </option>
				  <option 
				    value="<%=value_half%>"><%=text_half%>
				  </option>
				  <%}%>				   
		  		</select>
		  		<font style="<%=style3%>">*</font>
		  	</td>
		  	
		  	<td style="<%=style1%>">预约桌数</td>
		  	<td>
		  		<input type="text" id="demand_num" name="demand_num" style="<%=style2%>">
		  		<font style="<%=style3%>">*</font>
		  	</td>
		  	
		  	<td style="<%=style1%>">用餐人数</td>
		  	<td>
		  		<input type="text" id="staff_num" name="staff_num" style="<%=style2%>">
		  		<font style="<%=style3%>">*</font>
		  	</td>		  	
	  	</tr>
	  	
	  	<tr>
	  		<td style="<%=style1%>">用餐环境</td>
	  		<td style="<%=style4%>">
		  		<input type="radio" id="position_room" onclick="onClickRadio_position('position_room')" checked="checked">包厢
		  		<input type="radio" id="position_mall" onclick="onClickRadio_position('position_mall')">大厅
		  		<input type="radio" id="position_any" onclick="onClickRadio_position('position_any')">不限
		  		<font style="<%=style3%>">*</font>
		  	</td>
		  	
		  	<td style="<%=style1%>">预订要求</td>
		  	<td style="<%=style4%>">
		  		<input type="checkbox" id="window" name="window" />靠窗 
		  		<input type="checkbox" id="nosmoking" name="nosmoking" />无烟区
		  		<input type="checkbox" id="baby" name="baby" />宝宝椅
		  		<input type="checkbox" id=wc name="wc" />卫生间
		  	</td>
		  	
		  	<!-- 
		  	<td style="<%=style1%>">确认方式</td>
		  	<td style="<%=style4%>">
		  		<input type="checkbox" id="notice_phone" />电话 
		  		<input type="checkbox" id="notice_sms" />短信
		  		<font style="<%=style3%>">*</font>
		  	</td>
		  	 -->
		  	 
		  	<td style="<%=style1%>">加急</td>
		  	<td>
		  		<input type="checkbox" id="hurry" name="hurry" />
		  	</td>
	  	</tr>  	

	  	<tr>	  		
		  	
		  	<td style="<%=style1%>">附加要求</td>
		  	<td colspan="3">
		  		<textarea id="demand_addition" name="demand_addition" style="width=280px; height=80px"></textarea>
		  	</td>		  
		  	
		  	<td style="<%=style1%>"></td>
		  	<td>
		  		<input type="submit" value="生成订单" style="width: 80px;height: 40px;">
		  	</td>
	  	</tr>	  		  		  	 
	 	
	  	</table>
	  	
	  	<br/> 	
	  	<input type="checkbox" id="checkbox_autolock" name="checkbox_autolock" checked="checked" onclick="onClick_AutoLock()"/><font style="color: gray;font-style: italic" >自动预占</font>
	  		  	
	  	<input type = "hidden" id="business_id" name = "business_id" value="<%=business_id%>" >
	  	<input type = "hidden" id="cust_sex" name = "cust_sex" >
	  	<input type = "hidden" id="position_flag" name = "position_flag">
	  	<input type = "hidden" id="notice_flag" name = "notice_flag">
	  	
	  	<input type = "hidden" id="window_flag" name = "window_flag">
	  	<input type = "hidden" id="nosmoking_flag" name = "nosmoking_flag">
	  	<input type = "hidden" id="baby_flag" name = "baby_flag">
	  	<input type = "hidden" id="wc_flag" name = "wc_flag">
	  	<input type = "hidden" id="hurry_flag" name = "hurry_flag">
	  	
	  	<input type = "hidden" id="set_lockmanager_null" name = "set_lockmanager_null">
	  	
	  	
  	</form>
  	<iframe frameborder="0" src="<%=src%>" width="100%" height="660px" style="z-index:9"> 
  	</iframe>  	
  	
  	<SCRIPT LANGUAGE="JavaScript">
  		function onClickRadio_sex(id) {
  			var postfix = "";
  			if(id == 'sex_male') {
 				document.getElementById("sex_male").checked = true;
 				document.getElementById("sex_female").checked = false;
 				document.getElementById("sex_unknown").checked = false;
 				
 				postfix = "先生"; 				
 			} else if(id == 'sex_female'){
 				document.getElementById("sex_female").checked = true;
 				document.getElementById("sex_male").checked = false; 				
 				document.getElementById("sex_unknown").checked = false;
 				
 				postfix = "女士";
 			} else {
 				document.getElementById("sex_unknown").checked = true;
 				document.getElementById("sex_female").checked = false;
 				document.getElementById("sex_male").checked = false; 				
 			} 			
 			
 			var name = document.getElementById("cust_name").value;
 			var index = name.indexOf("先生");
 			if(index == -1) index = name.indexOf("女士");
 			if(index > -1 && name.length-2 == index) {
 				//存在"先生" 或 "女士"， 并且是在最后
 				name = name.substr(0,index);
 			}
 			document.getElementById("cust_name").value = name+postfix; 			
  		}
  		function onClickRadio_position(id) {
  			if(id == 'position_room') {
 				document.getElementById("position_room").checked = true;
 				document.getElementById("position_mall").checked = false;
 				document.getElementById("position_any").checked = false;
 			} else if(id == 'position_mall'){
 				document.getElementById("position_mall").checked = true;
 				document.getElementById("position_room").checked = false;
 				document.getElementById("position_any").checked = false;
 			} else {
 				document.getElementById("position_any").checked = true;
 				document.getElementById("position_mall").checked = false;
 				document.getElementById("position_room").checked = false;
 			}
  		}
  		function check() {
  	  		
  			var tmp;
			
  			tmp = document.getElementById("cust_tel").value;
  			if(IsPhone(tmp)==false) {
  	  			alert("请输入正确的客户电话号码,可以包括()、- 字符");
  	  			return false;
  			}
  			
  			tmp = document.getElementById("cust_name").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请输入客户姓名");
  	  			return false;
  			}
  			
  			tmp = document.getElementById("business_id").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请选择商家");
  	  			return false;
  			}

  			//预约时间
  			tmp = document.getElementById("demand_time_d").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请预约时间");
  	  			return false;
  			}
  			tmp = document.getElementById("demand_time_t").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请预约时间");
  	  			return false;
  			}
  			
  			tmp = document.getElementById("demand_num").value;
  			if(IsInteger(tmp)==false) {
  	  			alert("请正确输入预约桌数，只能为数字");
  	  			return false;
  			}
  			  
  			tmp = document.getElementById("staff_num").value;
  			if(IsEmpty(tmp)==true) {
  	  			alert("请填写用餐人数");
  	  			return false;
  			}
  			
  			if(document.getElementById("sex_male").checked == true) {
  				document.getElementById("cust_sex").value = 1;
  			} else if(document.getElementById("sex_female").checked == true) {
  				document.getElementById("cust_sex").value = 0;
  			} else {
  				document.getElementById("cust_sex").value = -1;
  			}
  			
  			if(document.getElementById("position_room").checked == true) {
  				document.getElementById("position_flag").value = 2;
  			} else if(document.getElementById("position_mall").checked == true) {
  				document.getElementById("position_flag").value = 1;
  			} else if(document.getElementById("position_any").checked == true) {
  				document.getElementById("position_flag").value = 0;
  			} else {
  				alert("请选择用餐环境");
  				return false;
  			}
  			
  			/* 去掉确认方式
  			if(document.getElementById("notice_phone").checked == true &&
  				document.getElementById("notice_sms").checked == true) {
  				document.getElementById("notice_flag").value = 3;
  			} else if(document.getElementById("notice_phone").checked == true) {
  				document.getElementById("notice_flag").value = 1;
  			} else if(document.getElementById("notice_sms").checked == true) {
  				document.getElementById("notice_flag").value = 2;
  			} else {
  				alert("请选择通知方式");
  				return false;
  			}
  			*/
  			
  			if(document.getElementById("window").checked == true) {
  				document.getElementById("window_flag").value = 1;
  			} else {
  				document.getElementById("window_flag").value = "";
  			} 
  			
  			if(document.getElementById("nosmoking").checked == true) {
  				document.getElementById("nosmoking_flag").value = 1;
  			} else {
  				document.getElementById("nosmoking_flag").value = "";
  			}
  			
  			if(document.getElementById("baby").checked == true) {
  				document.getElementById("baby_flag").value = 1;
  			} else {
  				document.getElementById("baby_flag").value = "";
  			}
  			
  			if(document.getElementById("wc").checked == true) {
  				document.getElementById("wc_flag").value = 1;
  			} else {
  				document.getElementById("wc_flag").value = "";
  			}
  			
  			if(document.getElementById("hurry").checked == true) {
  				document.getElementById("hurry_flag").value = 1;
  			} else {
  				document.getElementById("hurry_flag").value = "";
  			}
  			
  			return true;
  			
  		}
  	
  		function onClick_AutoLock() {
  			if(document.getElementById("checkbox_autolock").checked == true) {
  				document.getElementById("set_lockmanager_null").value = "";
  			} else {
  				document.getElementById("set_lockmanager_null").value = "1";
  			} 
  		}
  	</SCRIPT>
	</body>
</html>
